/****** Object:  StoredProcedure [dbo].[AuthZ_spGetPeople]    Script Date: 06/24/2009 23:43:37 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AuthZ_spGetPeople]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[AuthZ_spGetPeople]
GO

/****** Object:  StoredProcedure [dbo].[AuthZ_spGetPeople]    Script Date: 06/24/2009 23:43:37 ******/
SET ANSI_NULLS ON
GO

-- =============================================
-- Author:		<revans>
-- Create date: <4-20-2009>
-- Description:	<Retrieves information from Person table.>
-- Param:  EmployeeID
-- =============================================
CREATE PROCEDURE [dbo].[AuthZ_spGetPeople]
	
	@PersonnelNumbers as varchar(max)
	
AS
BEGIN
	BEGIN TRY
		SET NOCOUNT ON;
		
		--Returns all the people who match with the list of personnel numbers provided.
		SELECT  p.EMailName as 'Alias'
		, p.PersonID
		, p.FullName
		FROM Person p
		JOIN ISRM_ftStringToTable(@PersonnelNumbers, ',') pn
		ON   p.PersonnelNumber = pn.SplitValue
		ORDER BY p.FullName

	END TRY
	
	BEGIN CATCH
		DECLARE @ErrorMessage NVARCHAR(4000);
		DECLARE @ErrorSeverity INT;
		DECLARE @ErrorState INT;

		SELECT @ErrorMessage = ERROR_MESSAGE(),
			   @ErrorSeverity = ERROR_SEVERITY(),
			   @ErrorState = ERROR_STATE();
	           
		RAISERROR (@ErrorMessage, -- Message text.
				   @ErrorSeverity, -- Severity.
				   @ErrorState -- State.
				   );
	END CATCH
END

GO


